<?php
/***************************************
 *
 * @Repositories 模型层~数据表配置及自动验证等~~
 *
 **************************************/
namespace app\common\model;

use think\Model;
use think\Validate;


class FollowModel extends Model
{
    protected $autoWriteTimestamp = false;
    protected $updateTime = false;
    protected $createTime = false;
    /*
     * var string 数据表名
    */
    protected $table = 'click_follow';

    //自动验证
    protected $rule =   [
        'appid'  => 'require',
        'open_id'  => 'require',
    ];

    //验证返回结果
    protected $message  =   [
        'appid.require' => 'appid必须填写！',
        'open_id.require' => 'open_id必须填写！',
    ];

    /*添加数据时候验证字段是否匹配*/
    public function  checkData($data){
        $validate = new Validate($this->rule,$this->message);
        $data = $validate->check($data);
        if($data == false){
            $rsl_yz = $validate->getError();
            return  $rsl_yz;
        }else{
            return 'success';
        }
    }
}